function setCurrentMenu(i){
	var curMenu = "headerMenu_"+i;
	$("#"+curMenu).attr("class","main_top_headerMenuActive");
	$("div[id^=headerMenu]").each(function(){
		var iMenu=$(this).attr("id");
		if(iMenu!=curMenu)
			$(this).attr("class","main_top_headerMenu");
	});
}

function printOut(msg) {
	debug = false;
	if(!debug) return;
	var out = document.getElementById("PrintOutDiv");
	if (out == null) {
		out = document.createElement("div");
		out.id = "PrintOutDiv";
		out.style.float = "right";
		out.style.position = "fixed";
		out.style.right = 0;
		out.style.bottom = 0;
		document.body.appendChild(out);
	}
	out.innerHTML = out.innerHTML + "<br>" + msg;
}
//Vancl_ajax
//IE8 6001.18702版本可能会出现用户无法修改购物车商品数量，故用Vancl_ajax替代$.ajax
function Vancl_ajax(options) {
	var type = options.type || "POST";
	var url = options.url || "";
	var data = options.data || "";
	var dataType = options.dataType || options.datatype || "";
	var beforeSend = options.beforeSend || function(){};
	var success = options.success || function(){};
	var error = options.error || function(){};
	var complete = options.complete || function(){};
	var cache = options.cache || false;

	// 去除cache
	if (!cache) {
		//url = url += (url.indexOf("?") == -1 ? "?" : "&") + "timestamp=" + new Date().getTime();
		data= data+" timestamp=" + new Date().getTime()
	}

	var xhr = false;
	if (window.XMLHttpRequest) { // Mozilla
		xhr = new XMLHttpRequest();
		if (xhr.overrideMimeType) {
			xhr.overrideMimeType("text/xml");
		}
	} else if (window.ActiveXObject) { // IE
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}

	if (!xhr) {
		window.alert("Can't create XMLHttpRequest");
		return false;
	}
	if (dataType.toLowerCase() == "text") {
		// xhr.onreadystatechange = processTextResponse;
		xhr.onreadystatechange = function() {
			processTextResponse(xhr, success, error, complete);
		};
	} else if (dataType.toLowerCase() == "xml") {
		// xhr.onreadystatechange = processXMLResponse;
		xhr.onreadystatechange = function() {
			processXMLResponse(xhr, success, error, complete);
		};
	} else {
		// datatype默认为text
		xhr.onreadystatechange = function() {
			processTextResponse(xhr, success, error, complete);
		};
	}
	type = type.toUpperCase();
	if (type == "GET") {
		xhr.open(type, url, true);
	} else if (type == "POST") {
		xhr.open(type, url, true);
		xhr.setRequestHeader("content-Type", "application/x-www-form-urlencoded");
	} else {
		// 默认get
		xhr.open(type, url, true);
	}
	beforeSend();
	xhr.send(data);
}

function processTextResponse(xhr, success, error, complete) {
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			success(xhr.responseText);
		} else {
			error(xhr.responseText);
		}
		complete(xhr.responseText);
	}
}

function processXMLResponse(xhr, success, error, complete) {
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			success(xhr.responseXML);
		} else {
			error(xhr.responseXML);
		}
		complete(xhr.responseXML);
	}
}
